//
//  RootViewController.m
//  OCIOSDemo
//
//  Created by Caldremch on 2018/5/28.
//  Copyright © 2018年 Caldremch. All rights reserved.
//

#import "RootViewController.h"
#import "ModalViewController.h"

@interface RootViewController ()

@end

@implementation RootViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor purpleColor];
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    
    button.tag = 101;
    
    button.backgroundColor = [UIColor redColor];
    
    CGSize s = [UIScreen mainScreen].bounds.size;
    
    button.frame = CGRectMake(s.width/2 -140/2, s.height/2-40/2, 140, 40);
    
    [button setTitle:@"Present" forState:UIControlStateNormal];
    
    [button addTarget:self action:@selector(presentModalVc) forControlEvents:UIControlEventTouchUpInside];
    
    
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(s.width/2 -140/2, s.height/4, 140, 40)];
    
    label.text = @"Hello world";
    label.tag = 102;
    label.textAlignment = NSTextAlignmentCenter;
    label.backgroundColor = [UIColor redColor];
    label.textColor = [UIColor whiteColor];
    
    [self.view addSubview:label];
    
    [self.view addSubview:button];
    //
    //  [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceOrientation:) name:UIDeviceOrientationDidChangeNotification object:nil];
    
    
}


- (void) changeLabelText:(NSString*)text{
    
    UILabel *label = (UILabel *)[self.view viewWithTag:102];
    label.text = text;
    
}

-(void) presentModalVc{
    
    ModalViewController *modalVC = [[ModalViewController alloc] init];
    
//    modalVC.modalTransitionStyle = UIModalTransitionStylePartialCurl;
    
    //设置代理
    modalVC.delegate = self;
    
    
    
    [self presentViewController:modalVC animated:YES completion:^{
        NSLog(@"call back");
    }];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}



@end
